package programmercarl.贪心.C3;

class Solution {
    public int wiggleMaxLength(int[] nums) {
        //需要考虑四种情况的坡度和首尾的情况
        //平上，平下，上下，下上四种情况
        if (nums.length ==0 ||nums.length==1) return nums.length;
        int curr = 0;
        int prev = 0;
        //已经过滤掉1的情况
        int count = 1;
        for(int i = 1;i<nums.length;i++){
            curr=nums[i]-nums[i-1];
            if((curr>0&&prev<=0)||(curr<0&&prev>=0)){
                count++;
                prev=curr;
            }
        }
        return count;
    }
}